package com.cangxuan.backend.controller;

import com.cangxuan.backend.entity.Goods;
import com.cangxuan.backend.entity.MarketGoods;
import com.cangxuan.backend.service.IGoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("market")
@Api("市场数据控制器")
public class MarketController extends BaseController {
    IGoodsService goodsService;

    @Autowired
    public void setGoodsService(IGoodsService goodsService) {
        this.goodsService = goodsService;
    }

    @ApiModel("market请求实体类")
    @Data
    public static class MarketRequestBody {
        String searchKey; // 搜索关键字
        int category;  // 分类字段： 1.推荐 2.新品 4.综合
        int priceSort; // 价格排序 0升序 1降序
        int releaseDateSort; //发行时间排序 0升序 1降序
        Integer[] issuers; //发行方
        Integer[] series; //系列
        Integer pageIndex;
        Integer pageSize;
    }

    @PostMapping("list")
    @ApiOperation("市场藏品列表")
    public Object list(@RequestBody MarketRequestBody params) {
        System.out.println(params);
        List<MarketGoods> goodsList = goodsService.page(params.getSearchKey(),
                params.getCategory(),
                params.getPriceSort(),
                params.getReleaseDateSort(),
                params.getIssuers(),
                params.getSeries(),
                params.getPageIndex(),
                params.getPageSize());
        return success(goodsList);
    }



}
